const dbutil = require('../../../libs/MyDB');

module.exports = {
    //学生信息获取
    getInfo: async function () {
        let students = [];
        await dbutil.multiSelect('study_orderinfo', [`user_id`, `phone`, `password`, `token`, `studentId`, `user_detail_id`, `sex`, `description`, `realname`, `avater`, `edu`, `class_name`, `uname`, `uimg`])
            .then(
                result => {
                    students = result;
                }
            )
        return {
            code: 200,
            msg: "修改成功",
            students,
        }
    },
    setStudent: async function(data){
        await dbutil.update('study_user',`studentId=${data.studentId}`, {
            phone: data.phone,
            password: data.password,
        });
        return {
            code: 200,
            msg: "修改成功",
        }
    },
    getCommentInfo: async function(data){
        let comments = [];
        await dbutil.multiSelect('study_courseComment', [`course_comment_id`, `user_id`, `course_id`, `content`, `time`, `ctitle`],'user_id='+data.userId)
            .then(
                result => {
                    comments = result;
                }
            )
        return {
            code: 200,
            msg: "修改成功",
            comments,
        }
    },
    removeCommentInfo: async function(data){
        await dbutil.del('study_course_comment',`course_comment_id=${data.commentId}`);
        return {
            code: 200,
            msg: "删除成功",
        }
    }

}